package com.reservation.controller.admin.setting;

import com.reservation.dto.admin.setting.ModifyMeetingRoomDTO;
import com.reservation.result.Result;
import com.reservation.service.AdminHomeService;
import com.reservation.service.AdminSettingService;
import com.reservation.vo.admin.home.GetSystemInfo;
import com.reservation.vo.admin.setting.AddMeetingRoomVO;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Api(tags = "管理员设置相关接口")
@RestController
@RequestMapping("/api/admin")
@Slf4j
public class SettingController {

    @Autowired
    private AdminSettingService adminSettingService;

    /**
     * 添加会议室
     * @param vo
     * @return
     */
    @PostMapping("/addMeetingRoom")
    public Result addMeetingRoom(@RequestBody AddMeetingRoomVO vo) {

        return adminSettingService.addMeetingRoom(vo) ?Result.success("添加成功！") : Result.error("获取失败") ;
    }

    /**
     * 删除会议室
     * @param requestMap
     * @return
     */
    @PostMapping("/deleteMeetingRoom")
    public Result deleteMeetingRoom(@RequestBody Map<String, String> requestMap) {

        String id = requestMap.get("id");
        return adminSettingService.deleteMeetingRoom(Integer.parseInt(id)) ?Result.success("删除成功！") : Result.error("删除失败") ;
    }

    /**
     * 修改会议室
     * @param dto
     * @return
     */
    @PostMapping("/modifyMeetingRoom")
    public Result modifyMeetingRoom(@RequestBody ModifyMeetingRoomDTO dto) {
        System.out.println(dto.toString());

        return adminSettingService.updateMeetingRoom(dto) ?Result.success("更新成功！") : Result.error("更新失败") ;
    }



}
